<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%-- <%@ page import="java.text.SimpleDateFormat"%>  --%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查询订单明细</title>
<style type="text/css">
.totalPaidMoney span{
	display: inline-block;
}
.actionBtn{
	position: absolute;
	right: 50px;
	margin-top: 10px;
	margin-bottom: 10px
}
</style>

<%@ include file="/common/importLib.jsp" %>
<script type="text/javascript" src="../common/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">

	/**
	 * 增删改查参数设置
	 */
	/* toolbarView = 0;
	tableWidth = "100%";
	tableHeight = $(window).height()-110; */
	tableTitle = "订单明细表";
	tableColumns = [[
	                {field:'id',title:'id',width:0,rowspan:2},
	                {field:'code',title:'订单编号',width:180,rowspan:2},
					{field:'name',title:'订单名称',width:180,rowspan:2},	
					{field:'money',title:'价格（元）',width:70,rowspan:2},
					{field:'orderTimeString',title:'下单时间',width:150,rowspan:2},
					{field:'completeTimeString',title:'付款时间',width:150,rowspan:2},
					{field:'statusName',title:'状态',width:100,rowspan:2},
					{field:'paymentMethod',title:'支付方式',width:100,rowspan:2},
					{title:"购买人信息",width:200,colspan:2},
					{title:"推荐人信息",width:200,colspan:2}],
					[{field:'userName',title:'购买人姓名',width:100,rowspan:1,
						formatter:function(value,rowData,rowIndex){
							if(rowData.userName == null){
								return "";
							}else{
								return rowData.userName;
							}
						}
					 },
					 {field:'userMobilePhone',title:'手机号码',width:100,rowspan:1},
					 {field:'recommenderName',title:'推荐人姓名',width:100,rowspan:1,
						formatter:function(value,rowData,rowIndex){
							if(rowData.recommenderName == null){
								return "--";
							}else{
								return rowData.recommenderName;
							}
						 }
					  },
					 {field:'recommenderCode',title:'推荐码',width:100,rowspan:1,
						 formatter:function(value,rowData,rowIndex){
							if(rowData.recommenderCode == null){
								return "--";
							}else{
								return rowData.recommenderCode;
							}
						 }
					  }
					 ]]; 
	$(function(){
		combobox_1("statusId","../payment/userBalance/getOrderStatusList.do",true);
		combobox_1("paymentMethod","../payment/userBalance/getPayMethodList.do",false);
		$('#tt').tabs({
		    border:false,
		    onSelect:function(title){
				createTable(title);
		    }
		}); 
		$("#exportXls").on('click',exportXls);
	});
	
	var tableType = 2;
	function createTable(title){
		var productType = '';
		if(title == '套餐开通'){
			productType = 2;
			tableType = 2;
			tableURL = getTimeURL("../payment/userBalance/getOrderListByPage.do?typeId="+productType);
		}else if(title == '余额充值'){
			productType = 1;
			tableType = 1;
			tableURL = getTimeURL("../payment/userBalance/getOrderListByPage.do?typeId="+productType);
		}else if(title == '福卡激活'){
			productType = 3;
			tableType = 3;
			tableURL = getTimeURL("../payment/userBalance/getOrderListByPage.do?typeId="+productType);
		}else if(title == '课程包'){
			productType = 4;
			tableType = 4;
			tableURL = getTimeURL("../payment/userBalance/getOrderListByPage.do?typeId="+productType);
		}
		loadFirstPageData();
	}
	
	function exportXls(){
		var startTime = $("#starttime").val();
		var endTime = $("#endtime").val();
		var message = '';
		if(startTime){
			message = startTime + "至" + endTime;
		}else{
			if(endTime){
				message = "至" + endTime ;
			}else{
				message = "所有";
			}
		}
		var payMethod = $("#paymentMethod").combobox('getValue');
		var statusId = $("#statusId").combobox('getValue');
		$.messager.confirm('导出', '是否导出订单的表格（时间段：'+ message +'）？' ,function(r){
			if(r){
				location.href=getTimeURL("../payment/userBalance/exportPaymentList.do?startTimeString="+startTime+"&endTimeString="+endTime+"&typeId="+tableType + "&paymentMethod=" +payMethod + "&statusId=" +statusId);		
			}
		});
   }
	
	//表格成功加载的默认函数
	function defualtOnLoadSuccess(data){
		setTimeout(function() {	
			$("#datagrid_table").datagrid("clearSelections");
			$("#datagrid_table").datagrid("clearChecked");
			$(".xxl_linkbutton").linkbutton({plain:true});
			//MathJax.Hub.Queue(["Typeset",MathJax.Hub,document.getElementsByName("body")[0]]);
		}, 10);
		$("#totalNum").html(data.totalPaid);
		$("#totalMoney").html(data.totalPaidMoney);
		if(data.totalPaidName){
			$("#totalPaidName").html(data.totalPaidName+"：");
		}
	}

</script>
</head>
<body id="layout" class="easyui-layout">
	<div style="background: none repeat scroll 0% 0% #EFEFEF; height:140px; padding: 6px 2px; border-bottom: 1px solid #CCC;"
		region="north"  split="false" title="条件查询">
	<form  id="searchForm" >
	<table>
		<tr>
			<td width ="10px;"></td> <td><span style="font-size: 15px;color: red;">交易总量：</span></td><td><span style="font-size:20px;color:green" id="totalNum"></span></td>			
			<td width ="30px;"></td>
			<td>时间：</td><td><input type="text" name="startTimeString" id="starttime" style="width:120px;" class="input-style" onclick="WdatePicker({el:'starttime',maxDate:'#F{$dp.$D(\'endtime\')}',dateFmt: 'yyyy-MM-dd HH:mm:ss'})"/>
			<span style="padding: 0 6px 0 2px;">至</span><input type="text" name ="endTimeString" id="endtime"  style="width: 120px;" class="input-style" onclick="WdatePicker({el:'endtime',minDate:'#F{$dp.$D(\'starttime\')}',dateFmt: 'yyyy-MM-dd HH:mm:ss'})"/></td>
			<td width="50px;"></td>
			<td>推荐人：</td><td><input type="text" name="recommenderName" id="recommenderName"/></td>			
			<td width="50px;"></td>
			<td>支付类型：</td><td><input type="text" name="paymentMethod" id="paymentMethod"/></td>
			<td></td>
		</tr>
		<tr>		
			<td width ="10px;"></td><td><span style="font-size: 15px;color: red;" id="totalPaidName">交易总额：</span></td><td><span style="font-size:20px;color:green" id="totalMoney"></span></td>			
			<td width ="30px;"></td>
			<td>交易状态：</td><td><input type="text" name="statusId" id="statusId"/></td>			
			<td width="50px;"></td>			
			<td>订单编号：</td><td><input type="text" name="code" id="code"/></td>	
			<td width="50px;"></td>			
			<td>购买人号码：</td><td><input type="text" name="userMobilePhone" id="userMobilePhone"/></td>	
			<td width="50px;"></td>
		</tr>
		<tr class="actionBtn">
			<td><a class="easyui-linkbutton" id="search" iconCLs="icon-search"  onclick="searchTable();">搜索</a></td>
			<!--<td><a class="easyui-linkbutton" iconCls="icon-undo" onclick="document.getElementById('searchForm').reset();">清空</a></td>-->
			<td><a class="easyui-linkbutton" iconCLs="icon-excel" id="exportXls">导出</a></td>
		</tr>
	</table>
	</form>
	</div>
	<div region="center">
	<!-- datagrid信息表 -->
		<div id="tt" class="easyui-tabs">  
	      <div title="套餐开通" iconCls="icon-tip"></div>  
	      <div title="余额充值" iconCls="icon-tip"></div>
	      <div title="福卡激活" iconCls="icon-tip"></div>
	      <div title="课程包" iconCls="icon-tip"></div>
		</div>
	<table id="datagrid_table"></table>
		
	</div>
</body>
</html>